<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h2>链式调用</h2>
    <script src="./lib/axios.js"></script>
    <script>
      //  resolve   reject (形参) 名字可以改,但是建议别改
      const p = new Promise((resolve, reject) => {
        // 根据成功  resolve then
        setTimeout(() => {
          resolve('1')
        }, 1000)
      })

      // 只会触发一个
      const result = p
        .then((res) => {
          console.log('res:', res)
          return new Promise((resolve, reject) => {
            // 根据成功  resolve then
            setTimeout(() => {
              resolve('2')
            }, 2000)
          })
        })
        .then((res2) => {
          console.log('res2:', res2)
          return new Promise((resolve, reject) => {
            // 根据成功  resolve then
            setTimeout(() => {
              resolve('3')
            }, 3000)
          })
        })
        .then((res3) => {
          console.log('res3:', res3)
        })

      // console.log('result:', result)
    </script>
  </body>
</html>
